<%--
  Created by IntelliJ IDEA.
  User: baijinbao
  Date: 2020/11/17
  Time: 23:33
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>登录</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/layui/css/layui.css">
    <script src="${pageContext.request.contextPath}/layui/layui.js" charset="utf-8"></script>
    <style>
        .layui-input{
            width: 200px;
        }
        .max{
            margin: auto;
            margin-top: 170px;
            width: 400px;
        }
    </style>
</head>
<body>
<div class="layui-form max"> <!-- 提示：如果你不想用form，你可以换成div等任何一个普通元素 -->
    <div class="layui-form-item">
        <label class="layui-form-label">用户名</label>
        <div class="layui-input-block">
            <input type="text" name="username" id="username" placeholder="请输入用户名" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">密码</label>
        <div class="layui-input-block">
            <input type="password" name="password" id="pword" placeholder="请输入密码" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button id="sub" class="layui-btn" lay-submit lay-filter="*">登录</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
    <!-- 更多表单结构排版请移步文档左侧【页面元素-表单】一项阅览 -->
</div>
<script>
    /*$(".layui-btn").get({

    })*/
    layui.use(['element','layer'], function(){
        var $ = layui.jquery,
            element = layui.element;
        var layer = layui.layer;
        $("#sub").click(function (){
            var staffid =  $("#username").val();
            var password =  $("#pword").val();
            $.post(
                "${pageContext.request.contextPath}/staff/login",
                {staffid,password},
                function (bakedata){
                    if (bakedata.code==300){
                        layer.msg(bakedata.msg, {icon: 5});
                    }else{
                        //window.location.href = "homePage.jsp";
                        //表示登录成功，本来应该要直接跳转到管理系统首页，现在需要先去查询当前用户对应的权限
                        window.location.href = "menu/getAllMenuByRId";
                    }
                })
        })
    });


</script>
</body>
</html>
